package gstudio.views;

import gstudio.data.IData;
import gstudio.data.RuntimeDataManager;
import gstudio.ui.ListViewerFabrik;

import java.util.List;

import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

public class Satz_List extends ViewPart implements IPropertyChangeListener {
	private ListViewer listViewer;

	@Override
	public void createPartControl(Composite parent) {

		PropertyListenerManager.getInstance().register(this);
		listViewer = new ListViewerFabrik(parent, SWT.NONE).getListViewer();
	}

	public void propertyChange(PropertyChangeEvent event) {
		Object obj = event.getNewValue();
		if (obj != null && obj instanceof IData) {
			IData artikel = (IData) obj;
			String ids = artikel.getValueOf("ids").trim();
			if (!ids.equals("")) {
				List<IData> input = RuntimeDataManager.getInstance()
						.getListByIds("satz", ids);
				listViewer.setInput(input);

			}
		}
	}

	@Override
	public void setFocus() {

	}

}
